package com.imchen.cms.cmscore.service;

import com.imchen.cms.cmscore.dao.UserTypeMapper;
import com.imchen.cms.cmscore.model.UserType;
import com.imchen.cms.exception.CmsException;
import com.imchen.cms.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author imchen
 * @create: 2019-01-31 10:27
 **/
@Service
public class UserTypeService implements BaseService<UserType>{

    @Autowired
    private UserTypeMapper mapper;

    @Override
    public HashMap<String, Integer> add(UserType userType) throws CmsException {
        int count=mapper.insertSelective(userType);
        int id =userType.getId();
        return ServiceUtil.toAddMap(count,id);
    }

    @Override
    public UserType findById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int removeById(int id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteById(int id) {
        return 0;
    }

    @Override
    public int update(UserType userType) {
        return mapper.updateByPrimaryKeySelective(userType);
    }
}
